var xmlHttpRequest = null;

function getXMLHttpRequest() {
	if(window.ActiveXObject) {
		try {
			return new ActiveXObject("Msxml2.XMLHTTP");
		} catch(e1) {
			try {
				return new ActiveXObject("Microsoft.XMLHTTP");
			} catch(e2) {
				return null;
			}
		}
	} else if(window.XMLHttpRequest) {
		return new XMLHttpRequest();
	} else {
		return null;
	}
}

function sendRequest(url, params, callback, method) {
	xmlHttpRequest = getXMLHttpRequest();
	var httpMethod = method ? method : 'GET';
	
	if(httpMethod != 'GET' && httpMethod != 'POST') {
		httpMethod = 'GET';
	}
	
	var httpParams = (params == null || params == '') ? null : params;
	var httpUrl = url;
	
	if(httpMethod == 'GET' && httpParams != null) {
		httpUrl = httpUrl + "?" + httpParams;
	}
	
	xmlHttpRequest.open(httpMethod, httpUrl, true);
	xmlHttpRequest.onreadystatechange = callback;
	xmlHttpRequest.send(httpMethod == 'POST' ? httpParams : null);
	
	return xmlHttpRequest;
}